package controller;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.AddItemDAO;
import dao.GetPriceResearchDAO;
import dao.GetSearchKeywordsRecommendationDAO;
import databean.ItemBean;
import databean.PriceResearchBean;
import formbean.AddItemForm;

public class GetPriceResearchAction extends Action{

	@Override
	public String perform(HttpServletRequest request,
			HttpServletResponse response) {
		
		
		String add=request.getParameter("add");
		
		//case the first time come
		if(add==null||add.length()==0){
			return "getPriceResearch.view";
		}
		
		//get user input information
		String keyword=request.getParameter("givenkeyword");		
		
		//update to ebay
		if(keyword!=null){
			List<PriceResearchBean> rs = GetPriceResearchDAO.getPriceResearch(keyword);
			
			request.setAttribute("timestamp", GetPriceResearchDAO.getTimestamp());
			request.setAttribute("processingTime", GetPriceResearchDAO.getProcessingTime());
			request.setAttribute("callsRemaining", GetPriceResearchDAO.getCallsRemaining());
						
			request.setAttribute("rq", keyword);
			request.setAttribute("rs", rs);
		}
		return "getPriceResearchResult.view";
	}

}
